Skip to main content

Defining the range on a slew of selectors

Different selectors allow you to define a range of desired results, like four specific lines from a table, or the fifth and sixth paragraph from a text. Defining a range is simple, but has some nice features.

Both positive or negative integers can be used as a range delimiter. A positive range delimiter defines where to start counting from the start of the table. A negative range delimiter counts backwards from the end of the table.

In the examples below, we try to handle every possible (meaningful) combination of positive and negative range delimiters.

rangeexplanation
1:12first twelve results
3:12nine results, beginning with the third
1:-1all the results (no matter how long the list)
1:-4all the results up to the fourth to last
7:-1all results up from the seventh
-7:-1the seven last results
-7:-4four results from the end of the list, starting at the seventh to last

What about this case: -10 : 9?

This case could have results: this range results in the intersection of the first nine and the last 10 results. However, it might also not yield anything, if the incoming list of results is bigger than 18.